#pragma once

#include "NFServerComm/NFServerCommon/NFIDescStore.h"
#include "NFServerComm/NFServerCommon/NFIDescTemplate.h"
#include "NFLogicCommon/NFDescStoreMacrosDefine.h"
#include "NFLogicCommon/NFDescStoreTypeDefines.h"
#include "E_VersionControl.nanopb.h"
#ifndef MAX_VERSIONCONTROL_VERSIONCONTROL_NUM
#define MAX_VERSIONCONTROL_VERSIONCONTROL_NUM 30
#endif

struct VersionControlVersionControlWorldIDZoneIDPlatType
{
	VersionControlVersionControlWorldIDZoneIDPlatType()
	{
		if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode()) {
			CreateInit();
		}
		else {
			ResumeInit();
		}
	}
	int CreateInit()
	{
		worldID=0;
		zoneID=0;
		platType=0;
		return 0;
	}
	int ResumeInit()
	{
		return 0;
	}
	int64_t worldID;
	int64_t zoneID;
	int64_t platType;
	bool operator==(const VersionControlVersionControlWorldIDZoneIDPlatType& data) const
	{
		 return worldID== data.worldID && zoneID== data.zoneID && platType== data.platType;
	}
	std::string ToString() const
	{
		std::stringstream ios;
		ios << worldID;
		ios << ",";
		ios << zoneID;
		ios << ",";
		ios << platType;
		return ios.str();
	}
};

namespace std
{
	template<>
	struct hash<VersionControlVersionControlWorldIDZoneIDPlatType>
	{
		size_t operator()(const VersionControlVersionControlWorldIDZoneIDPlatType& data) const
		{
			return NFHash::hash_combine(data.worldID,data.zoneID,data.platType);
		}
	};
}


class VersionControlVersionControlDesc : public NFI_DESC_TEMPLATE_MACRO(VersionControlVersionControlDesc, E_VersionControlVersionControl, EOT_CONST_VERSIONCONTROL_VERSIONCONTROL_DESC_ID, MAX_VERSIONCONTROL_VERSIONCONTROL_NUM)
public:
	VersionControlVersionControlDesc();
	virtual ~VersionControlVersionControlDesc();
	int CreateInit();
	int ResumeInit();
public:
	int Load(NFResDb *pDB) override;
	int LoadDB(NFResDb *pDB) override;
	int CheckWhenAllDataLoaded() override;
	const E_VersionControlVersionControl* GetDescByWorldIDZoneIDPlatType(int64_t worldID, int64_t zoneID, int64_t platType);
private:
	NFShmHashMap<VersionControlVersionControlWorldIDZoneIDPlatType, uint64_t, MAX_VERSIONCONTROL_VERSIONCONTROL_NUM> m_worldIDZoneIDPlatTypeComIndexMap;
};
